package org.example;

import java.io.File;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) {
        String fileName = "";
        /*读取桌面指定文件夹*/
        String path = "休息休息";
        File file = new File(path);
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (File f : files) {
                fileName = f.getName();
                System.out.println("fileName = " + fileName);
                if (f.isDirectory()) {
                    File[] files1 = f.listFiles();
                    if (files1==null) {
                        continue;
                    }
                    for (File file1 : files1) {
                        if (file1.isDirectory()) {
                            File[] files2 = file1.listFiles();
                            if (files2!=null&&files2.length>0) {
                                for (File file2 : files2) {
                                    int i = file2.getName().lastIndexOf(".");
                                    String substring = file2.getName().substring(i);
                                    file2.renameTo(new File(path + "\\" + fileName + substring));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
